<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/common/CimsCommon.jsp"%>
<link rel="stylesheet" href="<%=basePath%>/css/cims/cmmBase.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<body style="background-color:#FFFFFF">
	<div id="formPageSwap">
		<br />
		<form id="addNewsFormData" name="addNewsFormData" isCheck="true"
			action="com.jy.modules.common.tcmmquota.controller.TCMmQuotaController">
			<input type=hidden id="dealCode" name="dealCode" value="${dealCode}" />
			<input type=hidden id="settleFlag" name="settleFlag" value="after" />
			<div class="expandSwap">
				<div class="ui-widget-header ui-corner-all">
					<span class="text">合约信息</span>
				</div>
				<div class="expandContent">
					<%@include file="contractContent.jsp"%>
				</div>

				<div class="ui-widget-header ui-corner-all">
					<span class="text">债权操作</span>
				</div>
				<div class="expandContent">
					<table id="updateNewsTableId" class="formTableSwap" border="0"
						align="center" cellpadding="0" cellspacing="1">
						<tr>
							<th>债权包：</th>
							<td>
								<div class="ui-widget">
									<input type="text" class="text cims_noborder"
										id="selectPackageName" name="selectPackageName"
										value="${dealDto.creditPackageName}" readonly /> <input
										type="hidden" class="text cims_noborder" id="selectPackage"
										name="selectPackage" value="${dealDto.creditPackageName}" />
								</div></td>
							<th id="settleHead">结算日期：</th><!-- //cims_noborder 无框样式-->
							<td>
								<input type="text" class="text" id="idSettleDate" name="settle" value="${settleDate}" notNull="false" readonly/>
							</td>
							<th> 账单日(始)：</th>
						   <td>
						   	<input type="text"  class="text cims_noborder" id="statementDateStart" name="statementDateStart"  value="${packageDto.billDate}">
						  </td>
						</tr>
						
						<tr>
							<th> 账单日(止)：</th>
						   <td>
						   	<input type="text"  class="text cims_noborder" id="statementDateEnd" name="statementDateEnd" value="${packageDto.billDateEnd}">
						  </td>
						  
						  <th> 还款方式：</th>
						  <td colspan="4"> 
						<syscode:dictionary name="publicRepayType"  defaultValue="${packageDto.repayType}" codeType="CM_REPAYMENTWAY" id="publicRepayType"	
						       className="text" type="select"/>
						     </td> 
						  
						</tr>
						
					</table>
				</div>

				<div id="tableToolbar" class="tableToolbar" style="display:none;">
					<a href="javascript:void(0)" onclick="monthSettle()" index="0">导出</a>
				</div>

				<div id="list"></div>
				<div class="ui-widget-header ui-corner-all">
					<span class="text">结算信息</span>
				</div>
				<div class="expandContent">
					<table class="formTableSwap" border="0" align="center"
						cellpadding="0" cellspacing="1">
						<tr>
							<th>结算金额 ：</th>
							<td><input type="hidden" class="text cims_noborder"
								id="viewMonthSettle" name="viewMonthSettle"
								value="viewMonthSettle"> <input type="text"
								class="text cims_noborder" id="" name="" value="${dealDto.sumCreditorValue}" readonly /></td>
							<th>需匹配金额：</th>
							<td><input type="text" class="text cims_noborder" id=""
								name="" value="${dealDto.planSellSum}" readonly /></td>
							<th>返还金额：</th>
							<td><input type="text" class="text cims_noborder" id=""
								name="" value="${dealDto.deliverSum}" readonly /></td>
						</tr>
						<tr>
							<th>债权数目：</th>
							<td><input type="text" class="text cims_noborder"
								id="dtostartDate" name="" maxLength="4"
								value="${creditRightDto.detialNumber}"  readonly />
							</td>
							<th>实际匹配金额 ：</th>
							<td><input type="text" class="text cims_noborder"
								id="dtoinvalidDate" name="" value="${dealDto.practicalSellSum}"
								 readonly /></td>
							<th></th>
							<td></td>
						</tr>
					</table>
				</div>
				<div class="expandToolbar">
					<span class="submitBtn" onclick="parent.tabs.close();">关闭</span>
				</div>
			</div>
			<!-- 保存 关闭 按钮 在 查询页面进行控制 -->
		</form>

	</div>
	<script type="text/javascript"
		src="<%=basePath%>/js/cims/publicJs/importContract.js"></script>
</body>

<script type="text/javascript">
	var doAddFrom;
	function download() {
		var url = contextRootPath + "/export/monthSettle?contractCode="
				+ dtocontractCode.value + "&packageNum=" + selectPackage.value
				+ "&templateType=02" + "&dealCode=" + dealCode.value;
		Cmm.download(url);
	}
	$(document).ready(
					function() {
						$("#statementDateStart").attr("disabled","disabled");
						$("#statementDateEnd").attr("disabled","disabled");
						$("#publicRepayType").attr("disabled","disabled");
						checkedInit();//平台校验不兼容IE
						var isCreditBuy = '${isCreditBuy}';
						if(isCreditBuy=="true"){
							$("#settleHead").hide();
							$("#idSettleDate").hide();
							$("#idSettleDate").val("111");
						}
						var importBtn = $("#importContract"), select = $("#selectPackage"), table;
						select.on("change", function() {
							var value = $(this).val();
							value = value ? value : "000";
							table.url = table.url.split("=")[0] + "=" + value
									+ "&contractCode=" + dtocontractCode.value;
							table.query();;
						});
						importBtn.on("click",
										importContract(function(contractCode) {
											var url = contextRootPath
													+ "/tCMmQuota/queryOneContractAll?contractCode="
													+ contractCode;
											if (table) {
												table.url = table.url.split("=")[0]+ "=000";
												table.query();
											}
											jyAjax(
													url,
													null,
													function(msg) {
														//保存成功后，执行查询页面查询方法
														var v_status = msg.status;
														if (v_status.indexOf('ok') > -1) {
															var cdto = msg.data.cdto, cspDto = msg.data.cspDto, url;
															table = iframe.iframeObj["table"];
															url = table.url;

															$("input[name=contractCode]").val(cdto.contractCode);
															$("input[name=contractName]").val(cdto.contractName);
															$("input[name=cooperorgCode]").val(cdto.cooperorgCode);
															$("input[name=agreementCode]").val(cdto.agreementCode);
															$("input[name=agreementName]").val(cdto.agreementName);
															$("select[name=beforeSettleType]").val(cspDto&& cspDto.beforeSettleType);
															$("select[name=overdueType]").val(cspDto&& cspDto.overdueType);
															$("select[name=replaceType]").val(cspDto&& cspDto.replaceType);
															url = "${basePath}cooperorgDeal/getPackageList?contractCode="
																	+ contractCode;
															jyAjax(
																	url,
																	null,
																	function(
																			msg) {
																		//保存成功后，执行查询页面查询方法
																		var v_status = msg.status;
																		if (v_status.indexOf('ok') > -1) {
																			var array = [ "<option value=''>--请选择--</option>" ], data = msg.data;
																			data = data ? data: [];
																			$.each(data,
																							function(i,n) {
																								array.push("<option>"+ n.creditPackageName+ "</option>");
																							});
																			select.empty();
																			select.append(array.join(""));
																		}
																	});
														}
													});
										}));
						!$("#dealCode").val() && importBtn.trigger("click");

					});
</script>
<%@include file="queryTCMmQuotaCreditDetail.jsp"%>
</html>
